<template>
  <ContentWrap>
    <el-form :model="queryParams" ref="queryFormRef" label-width="auto" :inline="true">
      <el-form-item label="姓名" prop="name">
        <el-input
          v-model="queryParams.name"
          placeholder="请输入姓名"
          :clearable="true"
          @keyup.enter="getPage"
        />
      </el-form-item>
      <el-form-item>
        <el-button v-hasPermi="['fee:recharge:query']" @click="handleClickSearch">
          <Icon icon="ep:search" />
          搜索
        </el-button>
        <el-button @click="handleClickReset">
          <Icon icon="ep:refresh" />
          重置
        </el-button>
        <el-button v-hasPermi="['fee:recharge:queryDetail']" @click="handleClickQueryDetail">
          <Icon icon="ep:search" />
          预充值费用详情
        </el-button>
        <el-button v-hasPermi="['fee:recharge:queryFlow']" @click="handleClickQueryFlow">
          <Icon icon="ep:search" />
          预充值费用流水
        </el-button>
        <el-button v-hasPermi="['fee:recharge:recharge']" @click="handleClickRecharge">
          预充值
        </el-button>
      </el-form-item>
    </el-form>
    <Table
      :columns="columns"
      :page-param="queryParams"
      :adaptive="true"
      :page-data="queryData"
      save-key="FeeRecharge"
      height-per="90"
      @page-change="getPage"
      @row-dblclick="handleTableDblclick"
    />
  </ContentWrap>
  <FeeRechargeCreate ref="createRefForm" @success="getPage" />
  <FeeRechargeDetail ref="detailRefForm" @closed="getPage" />
  <FeeRechargeFlow ref="flowRefForm" />
</template>
<script setup name="FeeRecharge" lang="ts">
import * as FeeRechargeApi from '@/api/fee/feeRecharge'
import FeeRechargeCreate from './FeeRechargeCreate.vue'
import FeeRechargeDetail from './FeeRechargeDetail.vue'
import FeeRechargeFlow from './FeeRechargeFlow.vue'
const createRefForm = ref()
const detailRefForm = ref()
const flowRefForm = ref()
const queryFormRef = ref()
const queryParams = ref({
  name: undefined
})
const queryData = ref()
const columns = [
  {
    label: '姓名',
    prop: 'elder.name'
  },
  {
    label: '身份证号',
    prop: 'elder.identityCard'
  },
  {
    label: '手机号',
    prop: 'elder.mobile'
  },
  {
    label: '预充值费用总和',
    prop: 'totalRecharge'
  },
  {
    label: '创建时间',
    prop: 'createTime'
  }
]
/** 初始化 */
onMounted(() => {
  getPage()
})

/** 搜索按钮操作 */
const handleClickSearch = () => {
  getPage()
}

/** 重置按钮操作 */
const handleClickReset = () => {
  queryFormRef.value?.resetFields()
  handleClickSearch()
}

/** 预充值费用详情按钮操作 */
const handleClickQueryDetail = () => {
  detailRefForm.value.open()
}

/** 预充值费用流水按钮操作 */
const handleClickQueryFlow = () => {
  flowRefForm.value.open()
}

/** 预充值按钮操作 */
const handleClickRecharge = () => {
  createRefForm.value.open()
}

/** 处理响应事件  */
const getPage = async () => {
  queryData.value = await FeeRechargeApi.pageQuery(queryParams.value)
}

/** 处理table行双击事件 */
const handleTableDblclick = (row) => {
  flowRefForm.value.open(row.id)
}
</script>
